Thread: Threads }multithreading.

  1. #1
    Registered User
    Join Date
    Sep 2014
    Posts
    235

    Cool Library for loading images in PNG

    What's the best performance library for loading images in PNG?
    Last edited by barracuda; 01-29-2015 at 08:56 AM.

  2. #2
    Lurker
    Join Date
    Dec 2004
    Posts
    296
    EDIT: Hm, fail by me. I must have written my answer in the wrong thread. Sorry for the noise.

    EDIT2: Not fail by me, fail by the OP by reusing another thread to create a new thread.

    EDIT3: This thread is now in the wrong sub forum, could somebody move it?
    Last edited by Jimmy; 01-29-2015 at 09:10 AM.

  3. #3
    Ticked and off
    Join Date
    Oct 2011
    Location
    La-la land
    Posts
    1,728
    As far as I'm aware, libpng (which uses zlib for the actual compression) is not only the reference implementation, but is also the fastest portable one, too. There might be some special-purpose, limited-feature or limited-architecture implementations, but I would not expect them to have any significant speed boost.

    The compression used in PNG files is straightforward data compression. It uses the DEFLATE algorithm (Lempel-Ziv with Huffman encoding), the exact same as used for Java JAR archives (and lots of places elsewhere too), and was "standardized" two decades ago, in 1996, as RFC 1951.

    To get a faster PNG compressor/decompressor, you need to beat zlib in DEFLATE compression/decompression.

    Sure, there are sensational claims like in this Intel paper, which says it can compress a PNG file 4.5x faster than zlib, but if you read the summary, it also tells you ".. by sacrificing the compression a little bit". Heh.

    This is not to say you cannot beat zlib, as you certainly can, but that to get such a significant speedup that it would matter for PNG compression/decompression, you either need architecture-specific code, or reduce the compression rate. zlib is open (even for your own commercial projects; no need to disclose your own sources to anyone), as is libpng, so most people won't bother. Not even the commercial folks, just look at Oracle et al. For PNG files, zlib is plenty fast.

    Then again, you would have found this all out by yourself, had you bothered to Google a bit.

  4. #4
    Registered User
    Join Date
    Sep 2014
    Posts
    235
    Last year I found LodePNG. I like it because it was very simple to use, also has nice working examples as far as I remember, but I did not compare LodePNG with libpng so do not know what is faster.

  5. #5
    Ticked and off
    Join Date
    Oct 2011
    Location
    La-la land
    Posts
    1,728
    Haven't used or looked at LodePNG, but the comments I found (here, Victor's comment here assuming Mac Image I/O is still based on libpng, and so on) via a quick web search, all say they found it slower than libpng. Also, LodePNG seems to be quite memory-intensive; something you might check if working with large images. (Although computers have lots of memory nowadays, we also have lots of stuff running at the same time.)

  6. #6
    Registered User
    Join Date
    Sep 2014
    Posts
    235
    OK, thanks. I will try the libpng.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. threads inside threads problem
    By Ivan Mili in forum C++ Programming
    Replies: 4
    Last Post: 08-22-2014, 09:07 AM
  2. Replies: 22
    Last Post: 12-14-2012, 11:00 AM
  3. Threads , how? Portable Threads Library?
    By adderly in forum C++ Programming
    Replies: 3
    Last Post: 12-15-2011, 07:54 AM
  4. Replies: 5
    Last Post: 10-17-2008, 11:28 AM
  5. a point of threads to create multiple threads
    By v3dant in forum C Programming
    Replies: 3
    Last Post: 10-06-2004, 09:48 AM